package logic

import (
	"context"
	"course-admin/model"

	"course-admin/userrpc/internal/svc"
	"course-admin/userrpc/userrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type CommentGoodsListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCommentGoodsListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommentGoodsListLogic {
	return &CommentGoodsListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 商品所有评论
func (l *CommentGoodsListLogic) CommentGoodsList(in *userrpc.CommentGoodsListRequest) (*userrpc.CommentGoodsListResponse, error) {
	// todo: add your logic here and delete this line
	var goods model.Goods
	show := goods.GoodsShow(model.DB, in)
	show1 := model.CommentUserList(model.DB, in)

	return &userrpc.CommentGoodsListResponse{
		HeadImg:      show.HeadImg,
		Nickname:     show.Nickname,
		GoodsName:    show.GoodsName,
		GoodsPrice:   show.GoodsPrice,
		GoodsContent: show.GoodsContent,
		GoodsId:      show.GoodsId,
		List:         show1,
	}, nil
}
